{% extends 'base.html' %}
{% block title %}
组管理页
{% endblock %}
{% block part1 %}
    <li class="active">
        <a class="dropdown-toggle" href="#">
            <i class="icon-group"></i>
            <span>主机管理</span>
            <i class="icon-chevron-down"></i>
        </a>
        <ul class="active submenu" style="display: block">
            <li><a href="/user/serverlist">主机管理</a></li>
            <li><a href="/user/servergroup" class="active">主机组</a></li>
        </ul>
    </li>
{% endblock %}
{% block content %}
<!-- main container -->
    <div class="content">

        <!-- settings changer -->

        <div class="container-fluid">
            <div id="pad-wrapper">
                <!-- orders table -->
                <div class="table-wrapper orders-table section">
                    <div class="row-fluid head">
                        <div class="span12">
                            <h2>组列表</h2>
                        </div>
                    </div>

                    <div class="row-fluid filter-block">
                        <div class="pull-right">
                            <div class="btn-group pull-right">
                                <button class="glow left large">搜索</button>
                                <button class="glow right large">
                                    <a href="/user/addGroup">添加组</a>
                                </button>
                            </div>
                            <input type="text" class="search order-search" placeholder="Search for an order.." />
                        </div>
                    </div>

                    <div class="row-fluid">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th class="span2">
                                        <span class="line"></span>
                                        组名
                                    </th>
                                    <th class="span3">
                                        <span class="line"></span>
                                        组成员数量
                                    </th>
                                    <th class="span3">
                                        <span class="line"></span>
                                        组描述
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <!-- row -->
                                {% for group in sgroup %}
                                <tr class="first">
                                    <td>
                                        <a href="/user/groupdetail/{{ group.id }}">{{ group.groupname }}</a>
                                    </td>
                                    <td>
                                        {{ group.memberCount }}
                                    </td>
                                    <td>
                                        {{ group.description }}
                                    </td>
                                    <td>
                                        <span class="label label-info">关联</span>
                                        <span class="label label-info" id="{{ group.id }}" onclick="del(this.id)">删除</span>
                                        <span class="label label-info">修改</span>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- end orders table -->
            </div>
        </div>
    </div>
    <!-- end main container -->
{% endblock %}
{% block jspart1 %}
    function del(id){
    if(confirm("确认删除") == false)
    {
        return;
    }
    $.ajax(
            {
                type:"post",
                url:"http://{{ request.get_host }}/user/delGroup/",
                data:{'id': id},
                success:function(data){
                    if(data['status'] == 'success'){
                        window.location.reload()
                    }
                },
                error:function(err){
                    console.log(err)
                }
            }
    )
    }
{% endblock %}
